﻿#region Usings
using System;
using BK.BL;
using BK.Entities;
using BK.WebSite.AppCode;
using Lib.ApplicationBlocks.Modules.Web.General;
using Lib.Utils.WebUtils;
#endregion

namespace BK.WebSite.Controls
{
    public partial class CategoryEditControl : BkDataEditControl<CategoryEntity, Categories>
    {
        #region Instance Methods
        protected override void DoGetObjectFromEditor(CategoryEntity entity)
        {
            entity.Name = tbxName.Text;
            if (ParentId.HasValue)
                entity.ParentId.Value = ParentId.Value;
            entity.UserId.Value = UserProvider.GetCurrentUser().Id.Value;
        }

        protected override void DoPutObjectToEditor(CategoryEntity entity)
        {
            tbxName.Text = entity.Name;
        }

        protected override void PrepareEditor()
        {
        }

        protected void Page_Load(object sender, EventArgs e)
        {
        }
        #endregion

        #region Instance Properties
        public int? ParentId
        {
            get { return RequestManager.GetNullableInt(WebConstants.UrlParams.PARENT_ID); }
        }
        #endregion
    }
}